//
//  ZValuationViewController.m
//  DoctorFAQs
//
//  Created by zjq on 17/3/29.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZValuationViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "ZReplyDetailedViewController.h"
#import "ZLabelTools.h"
#import "ZDoctorView.h"

#import "ZPartyView.h"
#import "JTAlertView.h"

#import "ZPayViewController.h"// 支付
#import "ZDoctorViewController.h" // 医生主页
#import "ZShowBigImage.h" //点击查看大图
#import "ZAppraiseViewController.h"
#import <SDWebImage/UIButton+WebCache.h>
#import "SPVoiceManager.h"
static int zvButtontag = 500;
@interface ZValuationViewController (){
    ZPartyView * _consumerView; // 用户一栏
    // 病情描述
    UILabel * _describeLabel;
    UITextView * _describeTextView;
    //听语音
    UILabel * _voicelable;
    UIButton * _voiceBtn;
    // 图片部分
    UILabel * _consultLabel;
    UIButton * _imageBtn1;
    UIButton * _imageBtn2;
    UIButton * _imageBtn3;
    UILabel * _imageLabel1;
    UILabel * _imageLabel2;
    UILabel * _imageLabel3;
    
    ZDoctorView * _doctorView;// 医生一栏
    
    // 医生答复
    UILabel * _doctordescribeLabel;
    UITextView * _doctordescribeTextView;
    //听语音
    UILabel * _doctorvoicelable;
    UIButton * _doctorvoiceBtn;
    
    //跳转评价界面
    UIButton * _pingjiaBtn;
    // 两个时长的label
    UILabel * _voiceTime;
    UILabel * _d_voiceTime;
}

@property (nonatomic,strong) UIScrollView * mainScrollView;
@property (nonatomic,strong) ZDidRDetailModel * didRModel;
@property (nonatomic,strong) ZDoctorTModel * dModel;
@property (nonatomic,strong) LZUserInfo * userInfo;
@property (nonatomic,strong) ZShowBigImage * rBigView;
@property (nonatomic,strong) AVAudioPlayer *avPlay;
@property (nonatomic,strong) NSString * order_num;
@property (nonatomic,strong) UIToolbar * bar;
@property (nonatomic,strong) UIToolbar * bar2;
@property (nonatomic,strong) UIToolbar * bar3;
@end

@implementation ZValuationViewController
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if ([[SPVoiceManager defaultManager] isPlaying]) {
        [[SPVoiceManager defaultManager] stop];
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"医生回复";
    self.view.backgroundColor = [UIColor whiteColor];
    [self initialzeDatas];
    [self initlizeInterface];
}

- (void)initialzeDatas {
    _userInfo = [LZUserInfo getUserInfo];
}

- (void)initlizeInterface {
    //分享按钮
    UIButton * rightBtn = [[UIButton alloc] init];
    rightBtn.frame = CGRectMake(0, 0, 16, 13);
    [rightBtn setBackgroundImage:[UIImage imageNamed:@"btn_share"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * rightBitem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    
    self.navigationItem.rightBarButtonItem = rightBitem;
    [self makeAllSubView];
    [self addALLSubView];
    [self makeAllSubviewMasnoy];
    [self makeGrayView];
}
- (void)makeAllSubView {
    __weak typeof(self) weakSelf = self;
    _consumerView = [[ZPartyView alloc] init];// 用户
    _describeLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_describeLabel Textcolor:[UIColor blackColor] backColor:[UIColor whiteColor] Fontsize:16 context:@"病情描述" isCenter:NO];
    _describeTextView = [[UITextView alloc] init];
    _describeTextView.backgroundColor = KHColorFromRGB(0xf4f1ce);
    _describeTextView.editable = YES;
    
    _voicelable = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_voicelable Textcolor:[UIColor blackColor] backColor:[UIColor whiteColor] Fontsize:16 context:@"用户语音" isCenter:NO];
    
    _voiceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_voiceBtn setBackgroundImage:[UIImage imageNamed:@"user_voice"] forState:UIControlStateNormal];
    [_voiceBtn addTarget:self action:@selector(palyVoice:) forControlEvents:UIControlEventTouchUpInside];
    
    _consultLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_consultLabel Textcolor:[UIColor blackColor] backColor:[UIColor whiteColor] Fontsize:16 context:@"医生参考图" isCenter:NO];
    
    _imageBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [_imageBtn1 setImage:[UIImage imageNamed:@"Reference_picture"] forState:UIControlStateNormal];
    _imageBtn1.tag = zvButtontag + 1;
    [_imageBtn1 addTarget:self action:@selector(showrBigImageView:) forControlEvents:UIControlEventTouchUpInside];
    _imageBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [_imageBtn2 setImage:[UIImage imageNamed:@"Reference_picture"] forState:UIControlStateNormal];
    _imageBtn2.tag = zvButtontag + 2;
    [_imageBtn2 addTarget:self action:@selector(showrBigImageView:) forControlEvents:UIControlEventTouchUpInside];
    _imageBtn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    [_imageBtn3 setImage:[UIImage imageNamed:@"Reference_picture"] forState:UIControlStateNormal];
    _imageBtn3.tag = zvButtontag + 3;
    [_imageBtn3 addTarget:self action:@selector(showrBigImageView:) forControlEvents:UIControlEventTouchUpInside];
    _imageLabel1 = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_imageLabel1 Textcolor:KHGaryColor backColor:[UIColor whiteColor] Fontsize:14 context:@"发病部位" isCenter:YES];
    _imageLabel2 = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_imageLabel2 Textcolor:KHGaryColor backColor:[UIColor whiteColor] Fontsize:14 context:@"病例报告" isCenter:YES];
    _imageLabel3 = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_imageLabel3 Textcolor:KHGaryColor backColor:[UIColor whiteColor] Fontsize:14 context:@"X光片" isCenter:YES];
    //医生部分
    _doctorView = [[ZDoctorView alloc] init];
    _doctorView.GoDoctorVCBlock = ^() {
        [weakSelf GoDotorDetail];
    };
    
    _doctordescribeLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_doctordescribeLabel Textcolor:[UIColor blackColor] backColor:[UIColor whiteColor] Fontsize:16 context:@"医生回复" isCenter:NO];
    
    _doctordescribeTextView = [[UITextView alloc] init];
    _doctordescribeTextView.backgroundColor = KHGreenColor;
    _doctordescribeTextView .textColor = [UIColor whiteColor];
    _describeTextView.editable = NO;
    _doctordescribeTextView.editable = NO;
    _doctordescribeTextView.textColor = [UIColor whiteColor];
    
    _doctorvoicelable = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_doctorvoicelable Textcolor:[UIColor blackColor] backColor:[UIColor whiteColor] Fontsize:16 context:@"医生语音" isCenter:NO];
    
    _doctorvoiceBtn = [UIButton buttonWithType: UIButtonTypeCustom];
    [_doctorvoiceBtn setBackgroundImage:[UIImage imageNamed:@"doc_voice"] forState:UIControlStateNormal];
    [_doctorvoiceBtn addTarget:self action:@selector(palyDotorVoice:) forControlEvents:UIControlEventTouchUpInside];
    
    _pingjiaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_pingjiaBtn addTarget:self action:@selector(jumpPayViewController) forControlEvents:UIControlEventTouchUpInside];
    _pingjiaBtn.backgroundColor = KHGreenColor;
    [_pingjiaBtn setTitle:@"去评价" forState:UIControlStateNormal];
    [_pingjiaBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    _voiceTime = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_voiceTime Textcolor:[UIColor blackColor] backColor:[UIColor clearColor] Fontsize:14 context:@"" isCenter:NO];
    _voiceTime.textAlignment = NSTextAlignmentRight;
    _d_voiceTime = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_d_voiceTime Textcolor:[UIColor blackColor] backColor:[UIColor clearColor] Fontsize:14 context:@"" isCenter:NO];
    _d_voiceTime.textAlignment = NSTextAlignmentRight;
}
- (void)addALLSubView {
    [self.view addSubview:self.mainScrollView];
    [self.view addSubview:_pingjiaBtn];
    [self.mainScrollView addSubview:_describeLabel];
    [self.mainScrollView addSubview:_consumerView];
    [self.mainScrollView addSubview:_describeTextView];
    [self.mainScrollView addSubview:_voicelable];
    [self.mainScrollView addSubview:_voiceBtn];
    [self.mainScrollView addSubview:_consultLabel];
    [self.mainScrollView addSubview:_imageBtn1];
    [self.mainScrollView addSubview:_imageBtn2];
    [self.mainScrollView addSubview:_imageBtn3];
    [self.mainScrollView addSubview:_imageLabel1];
    [self.mainScrollView addSubview:_imageLabel2];
    [self.mainScrollView addSubview:_imageLabel3];
    
    [self.mainScrollView addSubview:_doctorView];
    [self.mainScrollView addSubview:_doctordescribeLabel];
    [self.mainScrollView addSubview:_doctordescribeTextView];
    [self.mainScrollView addSubview:_doctorvoicelable];
    [self.mainScrollView addSubview:_doctorvoiceBtn];
    
    [_voiceBtn addSubview:_voiceTime];
    [_doctorvoiceBtn addSubview:_d_voiceTime];
    
    
}
- (void)makeAllSubviewMasnoy {
    [_consumerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(self.mainScrollView);
        make.top.equalTo(self.mainScrollView).offset(10*ysIZE);
        make.height.offset(50*ysIZE);
    }];
    [_describeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_consumerView.mas_bottom).offset(16*ysIZE);
        make.width.equalTo(self.mainScrollView).multipliedBy(0.5);
        make.left.equalTo(self.mainScrollView).offset(10*xsIZE);
        make.height.mas_offset(16*ysIZE);
    }];
    [_describeTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_describeLabel.mas_bottom).offset(15*ysIZE);
        make.left.equalTo(self.mainScrollView).offset(10*xsIZE);
        make.width.offset(300*xsIZE);
        make.height.offset(160*ysIZE);
    }];
    [_voicelable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_describeTextView.mas_bottom).offset(20*ysIZE);
        make.left.width.height.equalTo(_describeLabel);
    }];
    [_voiceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_voicelable.mas_bottom).offset(14*ysIZE);
        make.left.equalTo(_voicelable);
        make.height.offset(40*ysIZE);
        make.width.offset(205*xsIZE);
    }];
    [_consultLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_voiceBtn.mas_bottom).offset(35*ysIZE);
        make.left.width.height.equalTo(_describeLabel);
    }];
    [_imageBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_consultLabel.mas_bottom).offset(15*ysIZE);
        make.left.equalTo(self.view).offset(25*xsIZE);
        make.width.offset(80*xsIZE);
        make.height.offset(80*xsIZE);
    }];
    [_imageBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_imageBtn1);
        make.left.equalTo(_imageBtn1.mas_right).offset(16*xsIZE);
    }];
    [_imageBtn3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_imageBtn2);
        make.right.equalTo(self.view.mas_right).offset(-20*xsIZE);
    }];
    [_imageLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_imageBtn1.mas_bottom).offset(15*ysIZE);
        make.centerX.equalTo(_imageBtn1);
        make.height.offset(14*xsIZE);
        make.width.equalTo(_imageBtn1).multipliedBy(0.8);
    }];
    [_imageLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_imageLabel1);
        make.centerX.equalTo(_imageBtn2);
    }];
    [_imageLabel3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_imageLabel2);
        make.centerX.equalTo(_imageBtn3);
    }];
    
    [_doctorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(self.mainScrollView);
        make.top.equalTo(_imageLabel1.mas_bottom).offset(35*ysIZE);
        make.height.offset(65*ysIZE);
    }];
    [_doctordescribeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.height.width.equalTo(_describeLabel);
        make.top.equalTo(_doctorView.mas_bottom).offset(15*ysIZE);
    }];
    [_doctordescribeTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(_describeTextView);
        make.height.offset(125*ysIZE);
        make.top.equalTo(_doctordescribeLabel.mas_bottom).offset(10*ysIZE);
    }];
    [_doctorvoicelable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.height.equalTo(_voicelable);
        make.top.equalTo(_doctordescribeTextView.mas_bottom).offset(25*ysIZE);
    }];
    [_doctorvoiceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.height.equalTo(_voiceBtn);
        make.top.equalTo(_doctorvoicelable.mas_bottom).offset(14*ysIZE);
    }];
    
    [_pingjiaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(self.view);
        make.bottom.equalTo(self.view);
        make.height.offset(50*ysIZE);
    }];
    [_voiceTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.centerY.equalTo(_voiceBtn);
        make.right.equalTo(_voiceBtn).offset(-15*xsIZE);
        make.width.equalTo(_voiceBtn).multipliedBy(0.5);
    }];
    [_d_voiceTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.centerY.equalTo(_doctorvoiceBtn);
        make.right.equalTo(_doctorvoiceBtn).offset(-15*xsIZE);
        make.width.equalTo(_doctorvoiceBtn).multipliedBy(0.5);
    }];
    
}
- (void)makeGrayView {
    UIView * garyView1 = [[UIView alloc] init];
    garyView1.backgroundColor = MYGRAYCOLOR;
    UIView * garyView2 = [[UIView alloc] init];
    garyView2.backgroundColor = MYGRAYCOLOR;
    UIView * garyView3 = [[UIView alloc] init];
    garyView3.backgroundColor = MYGRAYCOLOR;
    [self.mainScrollView addSubview:garyView1];
    [self.mainScrollView addSubview:garyView2];
    [self.mainScrollView addSubview:garyView3];
    [garyView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.left.equalTo(self.mainScrollView);
        make.height.offset(10*ysIZE);
    }];
    [garyView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_consumerView.mas_bottom);
        make.width.equalTo(_consumerView).multipliedBy(0.8);
        make.height.offset(1.5*ysIZE);
        make.centerX.equalTo(_consumerView);
    }];
    [garyView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_doctorView.mas_top);
        make.width.equalTo(_doctorView);
        make.height.offset(10*ysIZE);
        make.centerX.equalTo(_doctorView);
    }];
}
- (void)setPersonModel:(PersonInfoModel *)personModel {
    _personModel = personModel;
    _consumerView.perModel = _personModel;
}
- (void)setQId:(NSString *)qId {
    _qId = qId;
    [self replyDetailNetWorking];
}

- (void)replyDetailNetWorking {
    NSDictionary * dict = @{@"pid":self.qId};
    [YJProgressHUD showProgress:@"正在加载" inView:self.view];
    [BaseRequest requestWithMethodResponseJsonByGet:TestURL paramars:dict paramarsSite:@"Index/answerDetails" sucessBlock:^(id content) {
        NSDictionary * rdict = [NSJSONSerialization JSONObjectWithData:content options:NSJSONReadingMutableContainers error:nil];
        LZLog(@"yishenhuifu%@",rdict);
        if ([rdict[@"code"] isEqualToString:@"1"]) {
            [YJProgressHUD showMessage:@"加载成功" inView:self.view];
            [self hanldReplyData:[rdict[@"list"] mutableCopy]];
            self.order_num = rdict[@"order_num"];
        }else {
            [YJProgressHUD showMessage:@"加载失败" inView:self.view];
        }
        
        
    } failure:^(NSError *error) {
        [YJProgressHUD showMessage:@"网络请求失败" inView:self.view];
    }];
}

- (void)hanldReplyData:(NSMutableDictionary * )dict {
    self.didRModel = [[ZDidRDetailModel alloc] initWithDict:dict];
    self.dModel = [[ZDoctorTModel alloc] initWithDict:dict];
    
}
//获得模型数据后
- (void)setDidRModel:(ZDidRDetailModel *)didRModel {
    _didRModel = didRModel;
    _describeTextView.text = _didRModel.title;
    [_imageBtn1 sd_setImageWithURL:[NSURL URLWithString:_didRModel.part] forState: UIControlStateNormal placeholderImage:[UIImage imageNamed:@"Reference_picture"]];
    [_imageBtn2 sd_setImageWithURL:[NSURL URLWithString:_didRModel.report] forState: UIControlStateNormal placeholderImage:[UIImage imageNamed:@"Reference_picture"]];
    [_imageBtn3 sd_setImageWithURL:[NSURL URLWithString:_didRModel.xray] forState: UIControlStateNormal placeholderImage:[UIImage imageNamed:@"Reference_picture"]];
    _doctordescribeTextView.text = _didRModel.content;
    _voiceTime.text = _didRModel.voice_time;
    _d_voiceTime.text = _didRModel.d_voice_time;
   
    _consumerView.timeLabel.text = _didRModel.time;
    if ([_didRModel.voice isEqualToString:IconURL]) {
        _voiceBtn.hidden = YES;
    }
    if ([_didRModel.d_voice isEqualToString:IconURL]) {
        _doctorvoiceBtn.hidden = YES;
    }
    if (self.ishiden == NO) {
        if ([_didRModel.is_dim isEqualToString:@"1"]) {
            [_imageBtn1.imageView addSubview:self.bar];
            [_bar mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.equalTo(_imageBtn1);
            }];
            [_imageBtn2.imageView addSubview:self.bar2];
            [_bar2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.equalTo(_imageBtn2);
            }];
            [_imageBtn3.imageView addSubview:self.bar3];
            [_bar3 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.equalTo(_imageBtn3);
            }];
        }
    }

}

- (void)setDModel:(ZDoctorTModel *)dModel {
    _dModel = dModel;
    _doctorView.dModel = dModel;
}

//点击放大的效果
- (void)showrBigImageView:(UIButton * )sender {
    
    if (sender.tag - zvButtontag == 1) {
        self.rBigView.imageUrl =  _didRModel.part;
    }else if (sender.tag - zvButtontag == 2) {
        self.rBigView.imageUrl = _didRModel.report;
    }else if (sender.tag - zvButtontag == 3){
        self.rBigView.imageUrl = _didRModel.xray;
    }
    UIWindow * window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self.rBigView];// 添加
    [self
     .rBigView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.edges.equalTo(window);
     }];
}
//点击播放录音
- (void)palyVoice:(UIButton *)sender {
    if (!_didRModel || !_didRModel.d_voice || [_didRModel.voice isEqualToString:@""] ||[_didRModel.voice isEqualToString:IconURL] ) {
        [YJProgressHUD showMessage:@"用户未录音" inView:self.view];
        return;
    }
    NSURL * voiceUrl = [[NSURL alloc]initWithString:_didRModel.voice];
    NSData * audioData = [NSData dataWithContentsOfURL:voiceUrl];
    NSString *name = [NSString stringWithFormat:@"/data.aac"];
    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:name];
    [audioData writeToFile:filePath atomically:YES];
    NSURL *fileURL = [NSURL fileURLWithPath:filePath];
    
    [[SPVoiceManager defaultManager]playingMusicUrl:fileURL];
}
- (void)palyDotorVoice:(UIButton *)sender {
    if (!_didRModel || !_didRModel.d_voice || [_didRModel.voice isEqualToString:@""] ) {
        [YJProgressHUD showMessage:@"医生未录音" inView:self.view];
        return;
    }
    
    NSURL * voiceUrl = [[NSURL alloc]initWithString:_didRModel.d_voice];
    NSData * audioData = [NSData dataWithContentsOfURL:voiceUrl];
    NSString *name = [NSString stringWithFormat:@"/doctorData.aac"];
    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:name];
    [audioData writeToFile:filePath atomically:YES];
    NSURL *fileURL = [NSURL fileURLWithPath:filePath];
    
    [[SPVoiceManager defaultManager]playingMusicUrl:fileURL];
    
}


// 跳转到评论界面
- (void)jumpPayViewController {
    if (!self.order_num || [self.order_num isEqualToString:@""]) {
        return;
    }
    ZAppraiseViewController * ZAVC = [[ZAppraiseViewController alloc] init];
    ZAVC.order_num = self.order_num;
    [self.navigationController pushViewController:ZAVC animated:YES];
}
- (void)shareAction {
    if (_userInfo.uid && ![_userInfo.uid isEqualToString:@""]) {
        [YJProgressHUD showMessage:@"假装在分享" inView:self.view];
    }
}

//跳转医生主页
- (void)GoDotorDetail {
    if (!_dModel ||! _didRModel.did ||[_dModel.did isEqualToString:@""]) {
        return;
    }
    ZDoctorViewController * ZDVc = [[ZDoctorViewController alloc] init];
    ZDVc.did = self.dModel.did;
    [self.navigationController pushViewController:ZDVc animated:YES];
}

// lazy
- (UIScrollView *)mainScrollView {
    if (_mainScrollView) {
        return _mainScrollView;
    }
    _mainScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_Width, SCREEN_Height)];
    _mainScrollView.contentSize = CGSizeMake(SCREEN_Width,1.8*SCREEN_Height);
    return _mainScrollView;
}
- (ZShowBigImage *)rBigView {
    if (_rBigView) {
        return _rBigView;
    }
    _rBigView = [[ZShowBigImage alloc] init];
    return _rBigView;
}

- (UIToolbar *)bar {
    if (_bar) {
        return _bar;
    }
    _bar = [[UIToolbar alloc] initWithFrame:CGRectZero];
    _bar.barStyle = UIBarStyleBlackTranslucent;
    return _bar;
    
}
- (UIToolbar *)bar2 {
    if (_bar2) {
        return _bar2;
    }
    _bar2 = [[UIToolbar alloc] initWithFrame:CGRectZero];
    _bar2.barStyle = UIBarStyleBlackTranslucent;
    return _bar2;
    
}
- (UIToolbar *)bar3 {
    if (_bar3) {
        return _bar3;
    }
    _bar3 = [[UIToolbar alloc] initWithFrame:CGRectZero];
    _bar3.barStyle = UIBarStyleBlackTranslucent;
    return _bar3;
}

@end
